using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class APUserMap : EntityTypeConfiguration<APUser>
    {
        public APUserMap()
        {
            // Primary Key
            this.HasKey(t => t.APUserId);

            // Properties
            this.Property(t => t.UserName)
                .HasMaxLength(50);

            this.Property(t => t.Password)
                .IsFixedLength()
                .HasMaxLength(32);

            this.Property(t => t.NickName)
                .HasMaxLength(50);

            this.Property(t => t.PhotoUrl)
                .HasMaxLength(200);

            this.Property(t => t.CustomerId)
                .HasMaxLength(50);

            this.Property(t => t.School)
                .HasMaxLength(50);

            this.Property(t => t.UserType)
                .IsFixedLength()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("APUser");
            this.Property(t => t.APUserId).HasColumnName("APUserId");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.NickName).HasColumnName("NickName");
            this.Property(t => t.PhotoUrl).HasColumnName("PhotoUrl");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.School).HasColumnName("School");
            this.Property(t => t.UserType).HasColumnName("UserType");
            this.Property(t => t.Isvalid).HasColumnName("Isvalid");
            this.Property(t => t.CreatedDate).HasColumnName("CreatedDate");
            this.Property(t => t.UpdatedDate).HasColumnName("UpdatedDate");
        }
    }
}
